package jdklearning.reflect;




class A {
}

class B extends A {
}

public class AssignableFromTest {
    public static void main(String[] args) {

        A a = new A();
        B b = new B();
        A ba = new B();
        System.out.println("1-------------");
        System.out.println("A.class.isAssignableFrom(a.getClass()): " + A.class.isAssignableFrom(a.getClass()));
        System.out.println("B.class.isAssignableFrom(b.getClass()): " + B.class.isAssignableFrom(b.getClass()));
        System.out.println("A.class.isAssignableFrom(b.getClass())): " + A.class.isAssignableFrom(b.getClass()));
        System.out.println("B.class.isAssignableFrom(a.getClass())): " + B.class.isAssignableFrom(a.getClass()));
        System.out.println("A.class.isAssignableFrom(ba.getClass()): " + A.class.isAssignableFrom(ba.getClass()));
        System.out.println("B.class.isAssignableFrom(ba.getClass()): " + B.class.isAssignableFrom(ba.getClass()));
        System.out.println("2-------------");
        System.out.println("a.getClass().isAssignableFrom(A.class)" + a.getClass().isAssignableFrom(A.class));
        System.out.println("b.getClass().isAssignableFrom(B.class)" + b.getClass().isAssignableFrom(B.class));
        System.out.println("a.getClass().isAssignableFrom(B.class)" + a.getClass().isAssignableFrom(B.class));
        System.out.println("b.getClass().isAssignableFrom(A.class)" + b.getClass().isAssignableFrom(A.class));
        System.out.println("ba.getClass().isAssignableFrom(A.class)" + ba.getClass().isAssignableFrom(A.class));
        System.out.println("ba.getClass().isAssignableFrom(B.class)" + ba.getClass().isAssignableFrom(B.class));
        System.out.println("3-------------");
        System.out.println("Object.class.isAssignableFrom(b.getClass())" + Object.class.isAssignableFrom(b.getClass()));
        System.out.println("Object.class.isAssignableFrom(\"abc\".getClass())" + Object.class.isAssignableFrom("abc".getClass()));
        System.out.println("4-------------");
        System.out.println("\"a\".getClass().isAssignableFrom(Object.class)" + "a".getClass().isAssignableFrom(Object.class));
        System.out.println("\"abc\".getClass().isAssignableFrom(Object.class)" + "abc".getClass().isAssignableFrom(Object.class));
    }
}

